/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package axisandallies;

import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.Display;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;
import shapes.Square;

/**
 *
 * @author ctuchsch
 */
public class Menu
{

    private Square menu;
    private Square[] buttons;
    private float ButtonOffset = .1f;
    private Matrix4f modelMatrix = null;
    private Vector3f modelPos = null;
    private Vector3f modelAngle = null;
    private Vector3f modelScale = null;
    private FloatBuffer matrix44Buffer;

    public Menu()
    {
        menu = new Square(0, 0f, 0f, 1.6f, 1, 1);
        buttons = new Square[4];
        for(int i = 0; i < buttons.length;i++)
        {
            buttons[i] = new Square(0,(i*ButtonOffset),0,.2f,.1f,1);
        }        
        modelPos = new Vector3f(0, 0, 1);
        modelAngle = new Vector3f(1, 1, 1);
        modelScale = new Vector3f(1, 1, 1);
        matrix44Buffer = BufferUtils.createFloatBuffer(16);
        modelMatrix = new Matrix4f();
    }

    public float[] toFloatBuffer()
    {
        return menu.toFloatArray();
    }

    public int numVertex()
    {
        return menu.getNumVerts();
    }

    public byte[] getIndices()
    {
        return menu.getIndexBuffer();
    }

    public int getIndicesCount()
    {
        return menu.getIndicesCount();
    }

    public void applyTranslations()
    {
        modelMatrix = new Matrix4f();
        Matrix4f.scale(modelScale, modelMatrix, modelMatrix);
        Matrix4f.translate(modelPos, modelMatrix, modelMatrix);
        //  Matrix4f.rotate(200, new Vector3f(1,0,0), modelMatrix, modelMatrix);
    }

    public FloatBuffer getModelMatrix()
    {
        modelMatrix.store(matrix44Buffer);
        matrix44Buffer.flip();
        return matrix44Buffer;
    }
}
